package com.malamute.system.action.system;

import java.util.Map;

import org.apache.struts2.dispatcher.Dispatcher;

import com.malamute.core.action.BaseAction;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationManager;
import com.opensymphony.xwork2.config.RuntimeConfiguration;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.ResultConfig;

/**
 * @author Aceguan
 * @description 获取所有action
 * @date 2012-2-20 下午02:26:54
 * @version v1.0
 */
public class AdminRedirectAction extends BaseAction {

	/**
	 * serialVersionUID:TODO（用一句话描述这个变量表示什么）
	 */
	private static final long serialVersionUID = 1L;

	/*
	 * (non-Javadoc)
	 * 
	 * @return
	 * 
	 * @throws Exception
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		Dispatcher dispatcher = Dispatcher.getInstance();
		ConfigurationManager cm = dispatcher.getConfigurationManager();

		Configuration cf = cm.getConfiguration();
		RuntimeConfiguration rc = cf.getRuntimeConfiguration();
		Map<String, Map<String, ActionConfig>> d = rc.getActionConfigs();
		for (String namespace : d.keySet()) {
			Map<String, ActionConfig> a = d.get(namespace);
			for (String actionName : a.keySet()) {
				System.out.println(namespace + "&&" + actionName);
				ActionConfig ac = a.get(actionName);
				if (ac.getAllowedMethods().size() > 0) {
					System.out.println("ac.getClassName()" + ac.getClassName());
					System.out.println("methods " + ac.getMethodName());
					for (String result : ac.getResults().keySet()) {
						System.out.println("result:" + result);
						ResultConfig resultConfig = ac.getResults().get(result);
						System.out.println(resultConfig.getParams());
					}
				}
			}
		}
		return SUCCESS;
	}

}
